namespace LightBox.Providers
{
	using System;
	using System.Configuration.Provider;
	using System.Text;

	/// <summary>
	/// Common collection for <see cref="ImageProvider"/> types.
	/// </summary>
	public class ImageProviderCollection : ProviderCollection 
	{
		/// <summary>
		/// Gets the <see cref="ImageProvider"/> with the specified name.
		/// </summary>
		/// <param name="name">Name of the image provider.</param>
		/// <returns>An instance of <see cref="ImageProvider"/>.</returns>
		public new ImageProvider this[string name]
		{
			get { return (ImageProvider)base[name]; }
		}

		/// <summary>
		/// Adds the specified provider to the list.
		/// </summary>
		/// <param name="provider">Provider to add.</param>
		public override void Add(ProviderBase provider)
		{
			if (provider == null)
			{
				throw new ArgumentNullException("provider");
			}

			if (!(provider is ImageProvider))
			{
				throw new ArgumentException("Invalid provider type.");
			}

			base.Add(provider);
		}
	}
}